<?php
namespace Rcard\Model;

use Think\Model;
use Think\Hook;


class RcardTypeModel extends Model
{
    public function saveData($data = array())
    {
        $data = $this->create($data);
        if (!$data) return false;
        $result = $this->save($data);
        return $result;
    }

    /**
     * 添加邀请码类型信息
     * @param array $data
     * @return bool|mixed
     * @author 郑钟良<zzl@ourstu.com>
     */
    public function addData($data = array())
    {

        $data = $this->create($data);
        if (!$data) return false;
        $result = $this->add($data);
        return $result;
    }


    public function getSimpleList($map = array(), $field = 'id,title')
    {
        if (count($map)) {
            $data = $this->where($map)->field($field)->order('create_time desc')->select();
        } else {
            $data = $this->field($field)->order('create_time desc')->select();
        }
        return $data;
    }

    public function getData($map = array())
    {
        $data = $this->where($map)->find();

        return $data;
    }


}